﻿//-----------------------------------------------------------------------
// <copyright file="Order.cs" company="Craig Longford (deltawolf7@gmail.com)">
//     Copyright (c) Craig Longford. All rights reserved.
// </copyright>
//-----------------------------------------------------------------------

namespace Delta.Mercury.Business.Commerce
{
    using System;
    using System.Globalization;
    using Delta.Data.DataExpress;
    using Delta.Mercury.Business.Exceptions;
    using Delta.Mercury.Business.User;

    /// <summary>
    /// Order class
    /// </summary>
    [Serializable]
    public class Order : IdentifierBase, IDataServicable
    {
        #region Members
        /// <summary>
        /// Order number
        /// </summary>
        private string orderNumber;

        /// <summary>
        /// Order date
        /// </summary>
        private DateTime orderDate;

        /// <summary>
        /// Customer unique identifier
        /// </summary>
        private Guid customerGuid;

        /// <summary>
        /// Customer name
        /// </summary>
        private string customerName;

        /// <summary>
        /// Billing customer name
        /// </summary>
        private string billingName;

        /// <summary>
        /// Billing address line 1
        /// </summary>
        private string billingAddressLine1;

        /// <summary>
        /// Billing address line 2
        /// </summary>
        private string billingAddressLine2;

        /// <summary>
        /// Billing address line 3
        /// </summary>
        private string billingAddressLine3;

        /// <summary>
        /// Billing address city
        /// </summary>
        private string billingAddressCity;

        /// <summary>
        /// Billing address city
        /// </summary>
        private string billingAddressRegion;

        /// <summary>
        /// Billing address post code
        /// </summary>
        private string billingAddressPostCode;

        /// <summary>
        /// Delivery address customer name
        /// </summary>
        private string deliveryName;

        /// <summary>
        /// Delivery address line 1
        /// </summary>
        private string deliveryAddressLine1;

        /// <summary>
        /// Delivery address line 2
        /// </summary>
        private string deliveryAddressLine2;

        /// <summary>
        /// Delivery address line 3
        /// </summary>
        private string deliveryAddressLine3;

        /// <summary>
        /// Delivery address city
        /// </summary>
        private string deliveryAddressCity;

        /// <summary>
        /// Delivery address region
        /// </summary>
        private string deliveryAddressRegion;

        /// <summary>
        /// Delivery address post code
        /// </summary>
        private string deliveryAddressPostCode;

        /// <summary>
        /// Order status name
        /// </summary>
        private string orderStatusName;

        /// <summary>
        /// Order status unique indetifier
        /// </summary>
        private Guid orderStatusGuid;

        /// <summary>
        /// Creator name
        /// </summary>
        private string creatorName;

        /// <summary>
        /// Creator guid
        /// </summary>
        private Guid creatorGuid;

        /// <summary>
        /// Is new order
        /// </summary>
        private bool newOrder;
        #endregion

        #region Constructors
        /// <summary>
        /// Initializes a new instance of the Order class
        /// </summary>
        public Order()
            : base()
        {
            this.orderDate = DateTime.Now;
            this.orderNumber = string.Empty;
            this.customerGuid = Guid.Empty;
            this.customerName = "Unknown";
            this.billingAddressCity = string.Empty;
            this.billingAddressLine1 = string.Empty;
            this.billingAddressLine2 = string.Empty;
            this.billingAddressLine3 = string.Empty;
            this.billingAddressPostCode = string.Empty;
            this.billingAddressRegion = string.Empty;
            this.billingName = "Unknown";
            this.deliveryAddressCity = string.Empty;
            this.deliveryAddressLine1 = string.Empty;
            this.deliveryAddressLine2 = string.Empty;
            this.deliveryAddressLine3 = string.Empty;
            this.deliveryAddressPostCode = string.Empty;
            this.deliveryAddressRegion = string.Empty;
            this.deliveryName = "Unknown";
            this.BillingGuid = Guid.Empty;
            this.DeliveryGuid = Guid.Empty;
            this.orderStatusGuid = Guid.Empty;
            this.orderStatusName = "Unknown";
            this.creatorGuid = Guid.Empty;
            this.creatorName = "Unknown";
            this.OrderLines = new OrderLines();
            this.PaymentDate = DateTime.Now;
            this.BillingPhone = string.Empty;
            this.DeliveryPhone = string.Empty;
            this.ShippingPrice = 0.0M;
            this.ShippingService = string.Empty;
            this.ShippingServiceGuid = Guid.Empty;
            this.PaymentData = string.Empty;
            this.PaymentGuid = Guid.Empty;
            this.newOrder = true;
        }

        /// <summary>
        /// Initializes a new instance of the Order class
        /// </summary>
        /// <param name="user">User the order belongs to</param>
        /// <param name="billingAddress">Billing address of the user</param>
        /// <param name="deliveryAddress">Delivery address of the user</param>
        public Order(IUser user, Address billingAddress, Address deliveryAddress)
            : base()
        {
            if (billingAddress == null)
            {
                throw new ArgumentNullException("Billing address can't be null while creating new order");
            }

            if (deliveryAddress == null)
            {
                throw new ArgumentNullException("Delivery address can't be null while creating new order");
            }

            this.orderDate = DateTime.Now;
            this.orderNumber = string.Empty;
            this.customerGuid = user.Guid;
            this.customerName = user.Fullname;
            this.billingAddressCity = billingAddress.City;
            this.billingAddressLine1 = billingAddress.Line1;
            this.billingAddressLine2 = billingAddress.Line2;
            this.billingAddressLine3 = billingAddress.Line3;
            this.billingAddressPostCode = billingAddress.PostCode;
            this.billingAddressRegion = billingAddress.Region;
            this.billingName = user.Fullname;
            this.deliveryAddressCity = deliveryAddress.City;
            this.deliveryAddressLine1 = deliveryAddress.Line1;
            this.deliveryAddressLine2 = deliveryAddress.Line2;
            this.deliveryAddressLine3 = deliveryAddress.Line3;
            this.deliveryAddressPostCode = deliveryAddress.PostCode;
            this.deliveryAddressRegion = deliveryAddress.Region;
            this.deliveryName = user.Fullname;
            this.BillingGuid = billingAddress.Guid;
            this.DeliveryGuid = deliveryAddress.Guid;
            this.orderStatusGuid = Guid.Empty;
            this.orderStatusName = "Unknown";
            this.creatorGuid = user.Guid;
            this.creatorName = user.Fullname;
            this.OrderLines = new OrderLines();
            this.PaymentDate = DateTime.Now;
            this.BillingPhone = string.Empty;
            this.DeliveryPhone = string.Empty;
            this.ShippingPrice = 0.0M;
            this.ShippingService = string.Empty;
            this.ShippingServiceGuid = Guid.Empty;
            this.PaymentData = string.Empty;
            this.PaymentGuid = Guid.Empty;
            this.newOrder = true;
        }
        #endregion

        #region Properties
        /// <summary>
        /// Gets or sets the order lines
        /// </summary>
        public OrderLines OrderLines { get; set; }

        /// <summary>
        /// Gets the date the order was created
        /// </summary>
        public DateTime Date
        {
            get
            {
                return this.orderDate;
            }
        }

        /// <summary>
        /// Gets the order number of the order
        /// </summary>
        public string OrderNumber
        {
            get
            {
                return this.orderNumber;
            }
        }

        /// <summary>
        /// Gets the order status name
        /// </summary>
        public string OrderStatusName
        {
            get
            {
                return this.orderStatusName;
            }
        }

        /// <summary>
        /// Gets or sets the order status unique identifier
        /// </summary>
        public Guid OrderStatusGuid
        {
            get
            {
                return this.orderStatusGuid;
            }

            set
            {
                this.orderStatusGuid = value;

                if (value != Guid.Empty)
                {
                    OrderStatus status = OrderStatus.Load(value, false);
                    if (status != null)
                    {
                        this.orderStatusName = status.Name;
                    }
                    else
                    {
                        this.orderStatusName = "Unknown";
                    }
                }
            }
        }

        /// <summary>
        /// Gets or sets the customers unique identifier
        /// </summary>
        public Guid CustomerGuid
        {
            get
            {
                return this.customerGuid;
            }

            set
            {
                if (value != Guid.Empty)
                {
                    User user = User.Load(value, false);
                    if (user != null)
                    {
                        this.customerName = user.Fullname;
                    }
                    else
                    {
                        this.customerName = "Unknown";
                    }
                }

                this.customerGuid = value;
            }
        }

        /// <summary>
        /// Gets the customer name
        /// </summary>
        public string CustomerName
        {
            get
            {
                return this.customerName;
            }
        }

        /// <summary>
        /// Gets or sets the delivery address name
        /// </summary>
        public string DeliveryCustomerName
        {
            get
            {
                return this.deliveryName;
            }

            set
            {
                if (value.Length < 1)
                {
                    throw new InvalidLengthException("Delivery customer name must be a minimum of 1 characters.");
                }

                if (value.Length > 50)
                {
                    throw new InvalidLengthException("Delivery customer name must be a maximum of 50 characters.");
                }

                TextInfo info = CultureInfo.CurrentCulture.TextInfo;
                this.deliveryName = info.ToTitleCase(value);
            }
        }

        /// <summary>
        /// Gets or sets the delivery unique identifier
        /// </summary>
        public Guid DeliveryGuid { get; set; }

        /// <summary>
        /// Gets or sets the delivery address line 1
        /// </summary>
        public string DeliveryAddressLine1
        {
            get
            {
                return this.deliveryAddressLine1;
            }

            set
            {
                if (value.Length < 1)
                {
                    throw new InvalidLengthException("Delivery address line 1 must be a minimum of 1 characters.");
                }

                if (value.Length > 50)
                {
                    throw new InvalidLengthException("Delivery address line 1 must be a maximum of 50 characters.");
                }

                TextInfo info = CultureInfo.CurrentCulture.TextInfo;
                this.deliveryAddressLine1 = info.ToTitleCase(value);
            }
        }

        /// <summary>
        /// Gets or sets the delivery address line 2
        /// </summary>
        public string DeliveryAddressLine2
        {
            get
            {
                return this.deliveryAddressLine2;
            }

            set
            {
                if (value.Length < 1)
                {
                    throw new InvalidLengthException("Delivery address line 2 must be a minimum of 1 characters.");
                }

                if (value.Length > 50)
                {
                    throw new InvalidLengthException("Delivery address line 2 must be a maximum of 50 characters.");
                }

                TextInfo info = CultureInfo.CurrentCulture.TextInfo;
                this.deliveryAddressLine2 = info.ToTitleCase(value);
            }
        }

        /// <summary>
        /// Gets or sets the delivery address line 3
        /// </summary>
        public string DeliveryAddressLine3
        {
            get
            {
                return this.deliveryAddressLine3;
            }

            set
            {
                if (value.Length < 1)
                {
                    throw new InvalidLengthException("Delivery address line 3 must be a minimum of 1 characters.");
                }

                if (value.Length > 50)
                {
                    throw new InvalidLengthException("Delivery address line 3 must be a maximum of 50 characters.");
                }

                TextInfo info = CultureInfo.CurrentCulture.TextInfo;
                this.deliveryAddressLine3 = info.ToTitleCase(value);
            }
        }

        /// <summary>
        /// Gets or sets delivery address city
        /// </summary>
        public string DeliveryAddressCity
        {
            get
            {
                return this.deliveryAddressCity;
            }

            set
            {
                if (value.Length < 1)
                {
                    throw new InvalidLengthException("Delivery address city must be a minimum of 1 characters.");
                }

                if (value.Length > 30)
                {
                    throw new InvalidLengthException("Delivery address city must be a maximum of 50 characters.");
                }

                TextInfo info = CultureInfo.CurrentCulture.TextInfo;
                this.deliveryAddressCity = info.ToTitleCase(value);
            }
        }

        /// <summary>
        /// Gets or sets address region
        /// </summary>
        public string DeliveryAddressRegion
        {
            get
            {
                return this.deliveryAddressRegion;
            }

            set
            {
                if (value.Length < 1)
                {
                    throw new InvalidLengthException("Delivery address region must be a minimum of 1 characters.");
                }

                if (value.Length > 30)
                {
                    throw new InvalidLengthException("Delivery address region must be a maximum of 50 characters.");
                }

                TextInfo info = CultureInfo.CurrentCulture.TextInfo;
                this.deliveryAddressRegion = info.ToTitleCase(value);
            }
        }

        /// <summary>
        /// Gets or sets delivery address post code
        /// </summary>
        public string DeliveryPostCode
        {
            get
            {
                return this.deliveryAddressPostCode;
            }

            set
            {
                if (value.Length < 1)
                {
                    throw new InvalidLengthException("Delivery address post code must be a minimum of 1 characters.");
                }

                if (value.Length > 30)
                {
                    throw new InvalidLengthException("Delivery address post code must be a maximum of 10 characters.");
                }

                this.deliveryAddressPostCode = value.ToUpper();
            }
        }

        /// <summary>
        /// Gets or sets the delivery phone number
        /// </summary>
        public string DeliveryPhone { get; set; }

        /// <summary>
        /// Gets or sets the billing unique identifier
        /// </summary>
        public Guid BillingGuid { get; set; }

        /// <summary>
        /// Gets or sets the billing customer name
        /// </summary>
        public string BillingCustomerName
        {
            get
            {
                return this.billingName;
            }

            set
            {
                if (value.Length < 1)
                {
                    throw new InvalidLengthException("Billing customer name must be a minimum of 1 characters.");
                }

                if (value.Length > 50)
                {
                    throw new InvalidLengthException("Billing customer name must be a maximum of 50 characters.");
                }

                TextInfo info = CultureInfo.CurrentCulture.TextInfo;
                this.billingName = info.ToTitleCase(value);
            }
        }

        /// <summary>
        /// Gets or sets the billing address line 1
        /// </summary>
        public string BillingAddressLine1
        {
            get
            {
                return this.billingAddressLine1;
            }

            set
            {
                if (value.Length < 1)
                {
                    throw new InvalidLengthException("Billing address line 1 must be a minimum of 1 characters.");
                }

                if (value.Length > 50)
                {
                    throw new InvalidLengthException("Billing address line 1 must be a maximum of 50 characters.");
                }

                TextInfo info = CultureInfo.CurrentCulture.TextInfo;
                this.billingAddressLine1 = info.ToTitleCase(value);
             }
        }

        /// <summary>
        /// Gets or sets the billing address line 2
        /// </summary>
        public string BillingAddressLine2
        {
            get
            {
                return this.billingAddressLine2;
            }

            set
            {
                if (value.Length < 1)
                {
                    throw new InvalidLengthException("Billing address line 2 must be a minimum of 1 characters.");
                }

                if (value.Length > 50)
                {
                    throw new InvalidLengthException("Billing address line 2 must be a maximum of 50 characters.");
                }

                TextInfo info = CultureInfo.CurrentCulture.TextInfo;
                this.billingAddressLine2 = info.ToTitleCase(value);
            }
        }

        /// <summary>
        /// Gets or sets the billing address line 3
        /// </summary>
        public string BillingAddressLine3
        {
            get
            {
                return this.billingAddressLine3;
            }

            set
            {
                if (value.Length < 1)
                {
                    throw new InvalidLengthException("Billing address line 3 must be a minimum of 1 characters.");
                }

                if (value.Length > 50)
                {
                    throw new InvalidLengthException("Billing address line 3 must be a maximum of 50 characters.");
                }

                TextInfo info = CultureInfo.CurrentCulture.TextInfo;
                this.billingAddressLine3 = info.ToTitleCase(value);
            }
        }

        /// <summary>
        /// Gets or sets billing address city
        /// </summary>
        public string BillingAddressCity
        {
            get
            {
                return this.billingAddressCity;
            }

            set
            {
                if (value.Length < 1)
                {
                    throw new InvalidLengthException("Billing address city must be a minimum of 1 characters.");
                }

                if (value.Length > 30)
                {
                    throw new InvalidLengthException("Billing address city must be a maximum of 50 characters.");
                }

                TextInfo info = CultureInfo.CurrentCulture.TextInfo;
                this.billingAddressCity = info.ToTitleCase(value);
            }
        }

        /// <summary>
        /// Gets or sets billing address region
        /// </summary>
        public string BillingAddressRegion
        {
            get
            {
                return this.billingAddressRegion;
            }

            set
            {
                if (value.Length < 1)
                {
                    throw new InvalidLengthException("Billing address region must be a minimum of 1 characters.");
                }

                if (value.Length > 30)
                {
                    throw new InvalidLengthException("Billing address region must be a maximum of 50 characters.");
                }

                TextInfo info = CultureInfo.CurrentCulture.TextInfo;
                this.billingAddressRegion = info.ToTitleCase(value);
            }
        }

        /// <summary>
        /// Gets or sets billing address post code
        /// </summary>
        public string BillingPostCode
        {
            get
            {
                return this.billingAddressPostCode;
            }

            set
            {
                if (value.Length < 1)
                {
                    throw new InvalidLengthException("Billing address post code must be a minimum of 1 characters.");
                }

                if (value.Length > 30)
                {
                    throw new InvalidLengthException("Billing address post code must be a maximum of 10 characters.");
                }

                this.billingAddressPostCode = value.ToUpper();
            }
        }

        /// <summary>
        /// Gets or sets the billing phone number
        /// </summary>
        public string BillingPhone { get; set; }

        /// <summary>
        /// Gets creator name
        /// </summary>
        public string CreatorName
        {
            get
            {
                return this.creatorName;
            }
        }

        /// <summary>
        /// Gets or sets the creator unique identifier
        /// </summary>
        public Guid CreatorGuid
        {
            get
            {
                return this.creatorGuid;
            }

            set
            {
                this.creatorGuid = value;

                if (this.creatorGuid != Guid.Empty)
                {
                    Delta.Mercury.Business.User.User user = Delta.Mercury.Business.User.User.Load(value, false);
                    if (user != null)
                    {
                        this.creatorName = user.Fullname;
                    }
                    else
                    {
                        this.creatorName = "Unknown";
                    }
                }
            }
        }

        /// <summary>
        ///  Gets or sets the date when payment was accepted
        /// </summary>
        public DateTime PaymentDate { get; set; }

        /// <summary>
        /// Gets or sets the payment data
        /// </summary>
        public string PaymentData { get; set; }

        /// <summary>
        /// Gets or sets the payment type guid
        /// </summary>
        public Guid PaymentGuid { get; set; }

        /// <summary>
        /// Gets or sets the shipping price
        /// </summary>
        public decimal ShippingPrice { get; set; }

        /// <summary>
        /// Gets or sets the shipping service
        /// </summary>
        public string ShippingService { get; set; }

        /// <summary>
        /// Gets or sets the shipping service guid
        /// </summary>
        public Guid ShippingServiceGuid { get; set; }
        #endregion

        #region Load Methods
        /// <summary>
        /// Load order by unique indetifier
        /// </summary>
        /// <param name="guid">Unique identifier</param>
        /// <param name="showDeleted">Show deleted</param>
        /// <returns>Filled order</returns>
        public static Order Load(Guid guid, bool showDeleted)
        {
            Parameters parameters = new Parameters();
            parameters.Add(new Parameter("Guid", guid));
            parameters.Add(new Parameter("Deleted", showDeleted));
            return DataAccess.GetSingle<Order>("LoadOrder", System.Data.CommandType.StoredProcedure, parameters);
        }

        /// <summary>
        /// Load order by order number
        /// </summary>
        /// <param name="orderNumber">Order number</param>
        /// <param name="showDeleted">Show deleted</param>
        /// <returns>Filled order</returns>
        public static Order Load(string orderNumber, bool showDeleted)
        {
            Parameters parameters = new Parameters();
            parameters.Add(new Parameter("OrderNumber", orderNumber));
            parameters.Add(new Parameter("Deleted", showDeleted));
            return DataAccess.GetSingle<Order>("LoadOrder", System.Data.CommandType.StoredProcedure, parameters);
        }
        #endregion

        #region Get Order Status
        /// <summary>
        /// Get order status
        /// </summary>
        /// <returns>Order status</returns>
        public OrderStatus GetOrderStatus()
        {
            return OrderStatus.Load(this.orderStatusGuid, false);
        }
        #endregion

        #region Get Delivery Address
        /// <summary>
        /// Get delivery address
        /// </summary>
        /// <returns>Delivery address</returns>
        public Address GetDeliveryAddress()
        {
            return Address.Load(this.DeliveryGuid, false);
        }
        #endregion

        #region Get Billing Address
        /// <summary>
        /// Get billing address
        /// </summary>
        /// <returns>Billing address</returns>
        public Address GetBillingAddress()
        {
            return Address.Load(this.BillingGuid, false);
        }
        #endregion

        #region Get Customer
        /// <summary>
        /// Get customer
        /// </summary>
        /// <returns>User object</returns>
        public Delta.Mercury.Business.User.User GetCustomer()
        {
            return Delta.Mercury.Business.User.User.Load(this.customerGuid, false);
        }
        #endregion

        #region Save Method
        /// <summary>
        /// Save order to database
        /// </summary>
        public void Save()
        {
            if (this.OrderNumber == string.Empty)
            {
                this.orderNumber = MercurySystem.GenerateOrderNumber();
            }
            
            DataAccess.NonQuery("SaveOrder", System.Data.CommandType.StoredProcedure, GetSaveParameters());

            if (this.newOrder)
            {
                this.newOrder = false;
                Settings.UpdateOrderNumber();
            }

            this.OrderLines.Save(this);
        }
        #endregion

        #region Delete Method
        /// <summary>
        /// Delete order
        /// </summary>
        public void Delete()
        {
            Parameters parameters = new Parameters();
            parameters.Add(new Parameter("Guid", this.Guid));
            DataAccess.NonQuery("DeleteOrder", System.Data.CommandType.StoredProcedure, parameters);
        }
        #endregion

        #region Fill Method
        /// <summary>
        /// Fill methods
        /// </summary>
        /// <param name="reader">Data reader</param>
        public void Fill(System.Data.IDataReader reader)
        {
            this.Guid = Helper.ToGuid(reader["Guid"]);
            this.orderDate = Helper.ToDateTime(reader["Date"]);
            this.orderNumber = Helper.ToString(reader["OrderNumber"]);
            this.customerGuid = Helper.ToGuid(reader["CustomerGuid"]);
            this.billingAddressCity = Helper.ToString(reader["BillingCity"]);
            this.billingAddressLine1 = Helper.ToString(reader["BillingLine1"]);
            this.billingAddressLine2 = Helper.ToString(reader["BillingLine2"]);
            this.billingAddressLine3 = Helper.ToString(reader["BillingLine3"]);
            this.billingAddressRegion = Helper.ToString(reader["BillingRegion"]);
            this.billingAddressPostCode = Helper.ToString(reader["BillingPostCode"]);
            this.BillingGuid = Helper.ToGuid(reader["BillingGuid"]);
            this.deliveryAddressCity = Helper.ToString(reader["DeliveryCity"]);
            this.deliveryAddressLine1 = Helper.ToString(reader["DeliveryLine1"]);
            this.deliveryAddressLine2 = Helper.ToString(reader["DeliveryLine2"]);
            this.deliveryAddressLine3 = Helper.ToString(reader["DeliveryLine3"]);
            this.deliveryAddressRegion = Helper.ToString(reader["DeliveryRegion"]);
            this.deliveryAddressPostCode = Helper.ToString(reader["DeliveryPostCode"]);
            this.DeliveryGuid = Helper.ToGuid(reader["DeliveryGuid"]);
            this.deliveryName = Helper.ToString(reader["DeliveryName"]);
            this.orderStatusName = Helper.ToString(reader["StatusName"]);
            this.orderStatusGuid = Helper.ToGuid(reader["StatusGuid"]);
            this.creatorName = Helper.ToString(reader["CreatorName"]);
            this.customerGuid = Helper.ToGuid(reader["CreatorGuid"]);
            this.PaymentDate = Helper.ToDateTime(reader["PaymentDate"]);
            this.DeliveryPhone = Helper.ToString(reader["DeliveryPhone"]);
            this.BillingPhone = Helper.ToString(reader["BillingPhone"]);
            this.ShippingPrice = Helper.ToDecimal(reader["ShippingPrice"]);
            this.ShippingService = Helper.ToString(reader["ShippingService"]);
            this.ShippingServiceGuid = Helper.ToGuid(reader["ShippingServiceGuid"]);
            this.PaymentData = Helper.ToString(reader["PaymentData"]);
            this.PaymentGuid = Helper.ToGuid(reader["PaymentGuid"]);

            this.OrderLines = OrderLines.Load(this);
        }
        #endregion

        #region Get Save Parameters
        /// <summary>
        /// Get save parameters
        /// </summary>
        /// <returns>Parameter collection</returns>
        public Parameters GetSaveParameters()
        {
            Parameters parameters = new Parameters();
            parameters.Add(new Parameter("Guid", this.Guid));
            parameters.Add(new Parameter("Date", this.Date));
            parameters.Add(new Parameter("OrderNumber", this.OrderNumber));
            parameters.Add(new Parameter("CustomerGuid", this.CustomerGuid));
            parameters.Add(new Parameter("CustomerName", this.CustomerName));
            parameters.Add(new Parameter("BillingCity", this.BillingAddressCity));
            parameters.Add(new Parameter("BillingLine1", this.BillingAddressLine1));
            parameters.Add(new Parameter("BillingLine2", this.BillingAddressLine2));
            parameters.Add(new Parameter("BillingLine3", this.BillingAddressLine3));
            parameters.Add(new Parameter("BillingRegion", this.BillingAddressRegion));
            parameters.Add(new Parameter("BillingPostCode", this.BillingPostCode));
            parameters.Add(new Parameter("BillingGuid", this.BillingGuid));
            parameters.Add(new Parameter("BillingName", this.BillingCustomerName));
            parameters.Add(new Parameter("DeliveryCity", this.DeliveryAddressCity));
            parameters.Add(new Parameter("DeliveryLine1", this.DeliveryAddressLine1));
            parameters.Add(new Parameter("DeliveryLine2", this.DeliveryAddressLine2));
            parameters.Add(new Parameter("DeliveryLine3", this.DeliveryAddressLine3));
            parameters.Add(new Parameter("DeliveryRegion", this.DeliveryAddressRegion));
            parameters.Add(new Parameter("DeliveryPostCode", this.DeliveryPostCode));
            parameters.Add(new Parameter("DeliveryGuid", this.DeliveryGuid));
            parameters.Add(new Parameter("DeliveryName", this.DeliveryCustomerName));
            parameters.Add(new Parameter("StatusGuid", this.OrderStatusGuid));
            parameters.Add(new Parameter("StatusName", this.OrderStatusName));
            parameters.Add(new Parameter("CreatorName", this.CreatorName));
            parameters.Add(new Parameter("CreatorGuid", this.CreatorGuid));
            parameters.Add(new Parameter("PaymentDate", this.PaymentDate));
            parameters.Add(new Parameter("BillingPhone", this.BillingPhone));
            parameters.Add(new Parameter("DeliveryPhone", this.DeliveryPhone));
            parameters.Add(new Parameter("ShippingPrice", this.ShippingPrice));
            parameters.Add(new Parameter("ShippingService", this.ShippingService));
            parameters.Add(new Parameter("ShippingServiceGuid", this.ShippingServiceGuid));
            parameters.Add(new Parameter("PaymentData", this.PaymentData));
            parameters.Add(new Parameter("PaymentGuid", this.PaymentGuid));
            return parameters;
        }
        #endregion
    }
}
